function Ankhy_Shaman_3()
	ccRS.Auto_Target = false
	ccRS.Auto_Facing = false
	
	local vToDispel = ccrFindDebuffInGroup("Mark of Arrogance")
	if vToDispel
		and SpellIsReady("Cleanse")
		and ccrPlayerHasDebuff("Gift of the Titans")
	then
		ccrCast("Cleanse", vToDispel)
		vToDispel = nil
		return
	end	
	if vToDispel
		and ccrTargetName() == "Sha of Pride"
		and ccrTargetHealth() <= 30
	then
		ccrCast("Cleanse", vToDispel)
		vToDispel = nil
		return
	end	
	
	------------------------
	-- TO DO LIST
	-- Heal the blobs on Immersius
	-- Heal and dispel the NPCs on Norushen
	-- Dispel Mark of Arrogance on Sha of Pride when have Gift of the Titans and when Sha have 30% or less health
	-- Stopcasting when Thok is casting Deafening Screech
	-- Cast Bulwark totem when 6 seconds left of "Iron Prison" debuff
	------------------------
	-- Conductivity
	local vTalent = {GetTalentInfo(15)}
	local vGotConductivity = false
	if vTalent[6] == true then vGotConductivity = true else vGotConductivity = false end
	----------------
	-- Totemic Persistance
	local vTalent = {GetTalentInfo(8)}
	local vGotPersistance = false
	if vTalent[6] == true then vGotPersistance = true else vGotPersistance = false end
	----------------------
	-- Cast Essential Buffs
	ccrCastBuffIfMissing("Water Shield")
	if GetWeaponEnchantInfo() == nil then ccrCast("Earthliving Weapon") end
	----------------------
--[[
	if ccrPlayerIsInCombat() then
		if tblTGetNearbyNPC ~= nil
		and #tblTGetNearbyNPC > 0 
		then
			for x = 1, #tblTGetNearbyNPC do
				local vNPC = tblTGetNearbyNPC[x]
				if vNPC
				and vNPC:Exists()
				and not vNPC:IsDead()
				and (
					vNPC:GetName() == "Contaminated Puddle"
					or vNPC:GetName() == "Leven Dawnblade"
					or vNPC:GetName() == "Rook Stonetoe"
					or vNPC:GetName() == "Sun Tenderheart"
					)
				then
					local vNPC_Health = (vNPC:GetHealth()/vNPC:GetMaxHealth()*100)
					if vNPC:GetAura("Lingering Corruption") ~= nil then
						vNPC:Target()
						vNPC:CastSpellByName("Purify Spirit")
					end
					if vNPC_Health < 100	then
						vNPC:Target()
						vNPC:CastSpellByName("Chain Heal")
					end
					if vNPC_Health < 100 then
						vNPC:Target()
						vNPC:CastSpellByName("Greater Heal")
					end
				end
			end
		end
	end
]]--
	--------------------------
	-- Find all nearby players
	Gather_Nearby_Players()
	--------------------------
	-- Autoaccept LFR invite
	AcceptProposal();
	--------------------------
	-- Autoaccept Readycheck
	ConfirmReadyCheck(1);
	--------------------------
	-- Autoaccept Resurrection
	AcceptResurrect();
	--------------------------
	-- Find who has the lowest health
	local vPlayerToHeal, vPlayerHealth = Find_Lowest_HP()
	if vPlayerToHeal ~= nil
	and vPlayerHealth ~= nil
	then
		-- Raid Specific
		if ccrUnitHasDebuff(vPlayerToHeal, "Strong Ancient Barrier", "any") then vPlayerHealth = 60 end
		if ccrUnitHasDebuff(vPlayerToHeal, "Ancient Barrier", "any") then vPlayerHealth = 40 end
		if ccrUnitHasDebuff(vPlayerToHeal, "Weak Ancient Barrier", "any") then vPlayerHealth = 25 end

		-----------

		-- Wait until casting is over 
		if ccrPlayerIsCastingOrChanneling() then return end
		
		if IsShiftKeyDown() then 
			if SpellIsReady("Unleash Elements") then ccrCast("Unleash Elements") end
				ccrCast("Healing Rain")
				CameraOrSelectOrMoveStart()
				CameraOrSelectOrMoveStop()
			return
		end
		if ccrTargetName("Thok the Bloodthirsty") and ccrTargetIsCastingSpell("Deafening Screech") and not ccrPlayerHasBuff("Devotion Aura")
				then
				SpellStopCasting()
				return
			end
		-- CD's in combat
		if IsMounted() == nil then
			if ccrPlayerIsInCombat() then
				-- Use trinkets in combat
				UseTrinkets();

				-- Use Mana Tide Totem if low on mana
				if vGotPersistance then
					if ccrPlayerMana() <= 70
					and SpellIsReady("Mana Tide Totem")
					then
						ccrCast("Mana Tide Totem")
					end
				else
					-- if mana is at 50% and no healing stream totem is up, use mana tide 
					if ccrPlayerMana() <= 75
					and not TotemExists("Healing Stream Totem")
					and SpellIsReady("Mana Tide Totem")
					then
						ccrCast("Mana Tide Totem")
					end
				end

				-- If we dont have Healing Stream Totem in use
				if not onCD("Healing Stream Totem")
				then
					-- If oom then wait for regen
					if NotEnoughMana("Healing Stream Totem") then
						return
					end

					-- Totem is ready to be used
					if SpellIsReady("Healing Stream Totem") then ccrCast("Healing Stream Totem") end
				end
				-- Earth Elemental: Reinforce
				if SpellIsReady("Reinforce") then ccrCast("Reinforce") end
				-- Fire Elemental: Empower
				if SpellIsReady("Empower") then ccrCast("Empower") end
			
			end
			--------------------------------- Dispel ---------------------------------
				if SpellIsReady("Purify Spirit") then
					if ccrUnitHasDebuffStacks(vPlayerToHeal, "Shadow Word: Bane", 2, "any")
					or ccrUnitHasDebuff(vPlayerToHeal, "Lingering Corruption")
					or ccrUnitHasDebuff(vPlayerToHeal, "Self-Absorbed")
					or ccrUnitHasDebuffStacks(vPlayerToHeal, "Corrosive Blood", 1, "any")
					then
						ccrCast("Purify Spirit", vPlayerToHeal)
					end
				end
				local vPlayerWithDebuff = ccrFindDebuffInGroup("Mark of Arrogance")
		if vPlayerWithDebuff ~= nil
			and ccrPlayerHasDebuff("Gift of the Titans")
			and ccrSpellIsReady("Purify Spirit")
			then
				ccrCast("Purify Spirit", vPlayerWithDebuff)
		return
		end
		if vPlayerWithDebuff ~= nil
			and ccrTargetName() == "Sha of Pride"
			and ccrTargetHealth() <= 30
			and ccrSpellIsReady("Purify Spirit")
			then
				ccrCast("Purify Spirit", vPlayerWithDebuff)
		return
		end
			--------------------------------- LMG ---------------------------------
			-- Unleashed Elements + Healing Rain 3+ at 100% with Lucidity
			if vPlayerHealth <= 100
			and SpellIsReady("Unleash Elements")
			and not ccrPlayerHasBuff("Healing Rain")
			and (ccrPlayerHasBuff("Spiritwalker's Grace") or not ccrPlayerIsMoving())
			and ccrPlayerHasBuff("Lucidy")
			then
				if GroupedPlayersHealth(vPlayerToHeal, 20, 100) >= 1
				and #tblGroupedPlayersHealth > 0 then
					if SpellIsReady("Unleash Elements") 
					then ccrCast("Unleash Elements") 
				end
					ccrCast("Healing Rain")
					if SpellIsTargeting() == 1 then CastAtLocation(GetAveragePositionOfObjects(tblGroupedPlayersHealth)) end
					return
				end
			end
			-- Chainheal 4+ is at 99% with lucidity
			if vPlayerHealth <= 99
			and ccrPlayerHasBuff("Lucidity")
			and SpellIsReady("Chain Heal")
			and (ccrPlayerHasBuff("Spiritwalker's Grace") or not ccrPlayerIsMoving())
			then
				if GroupedPlayersHealth(vPlayerToHeal, 40, 99) >= 3 then
					ccrCast("Chain Heal", vPlayerToHeal)
					if vTargetPlayerToHeal then TargetUnit(vPlayerToHeal) end
					return
				end
			end
			-- Healing Surge at 60% with Lucidity
			if vPlayerHealth <= 80
			and ccrPlayerHasBuff("Lucidity")
			and SpellIsReady("Healing Surge")
			and (ccrPlayerHasBuff("Spiritwalker's Grace") or not ccrPlayerIsMoving())
			then
				ccrCast("Healing Surge", vPlayerToHeal)
				if vTargetPlayerToHeal then TargetUnit(vPlayerToHeal) end
				return
			end
			--------------------------------- Encounter Specific ---------------------------------

			--------------------------------- TANK ---------------------------------
			-- Healing Surge at 30%
			if vPlayerHealth <= 30
			and UnitGroupRolesAssigned(vPlayerToHeal) == "TANK"
			and SpellIsReady("Healing Surge")
			and not ccrTargetName() == "Malkorok"
			and (ccrPlayerHasBuff("Spiritwalker's Grace") or not ccrPlayerIsMoving())
			then
				ccrCast("Healing Surge", vPlayerToHeal)
				if vTargetPlayerToHeal then TargetUnit(vPlayerToHeal) end
				return
			end
			-- Riptide and Earth Shield on Tanks at 100%
			if vPlayerHealth <= 100
			and UnitGroupRolesAssigned(vPlayerToHeal) == "TANK"
			then
				if not ccrUnitHasMyBuff(vPlayerToHeal, "Earth Shield") or ccrUnitHasBuffStacksLeft(vPlayerToHeal, "Earth Shield", 2)
				and SpellIsReady("Earth Shield")
				then
					ccrCast("Earth Shield", vPlayerToHeal)
					return
				end
				if not ccrUnitHasMyBuff(vPlayerToHeal, "Riptide")
				and UnitGroupRolesAssigned(vPlayerToHeal) == "TANK"
				and SpellIsReady("Riptide")
				then
					ccrCast("Riptide", vPlayerToHeal)
					return
				end
			end
			-- Greater Healing Wave at 60%
			if vPlayerHealth <= 50
			and SpellIsReady("Greater Healing Wave")
			and not ccrTargetName() == "Malkorok"
			and not GroupedPlayersHealth(vPlayerToHeal, 20, 80) >= 3
			and (ccrPlayerHasBuff("Spiritwalker's Grace") or not ccrPlayerIsMoving())
			then
				ccrCast("Greater Healing Wave", vPlayerToHeal)
				if vTargetPlayerToHeal then TargetUnit(vPlayerToHeal) end
				return
			end
			--------------------------------- RAID ---------------------------------
				-- Chainheal and Ancestral Swiftness at 80% 4+
			if vPlayerHealth <= 85
			and SpellIsReady("Chain Heal")
			and (ccrPlayerHasBuff("Spiritwalker's Grace") or not ccrPlayerIsMoving())
			then
				if GroupedPlayersHealth(vPlayerToHeal, 40, 85) >= 4 then
					if not ccrPlayerIsCastingSpell("Chain Heal")
						then SpellStopCasting() end 
					if SpellIsReady("Ancestral Swiftness") then ccrCast("Ancestral Swiftness") end
					ccrCast("Chain Heal", vPlayerToHeal)
					if vTargetPlayerToHeal then TargetUnit(vPlayerToHeal) end
					return
				end
			end
			-- Chainheal at 95% 3+
			if vPlayerHealth <= 77
			and SpellIsReady("Chain Heal")
			and (ccrPlayerHasBuff("Spiritwalker's Grace") or not ccrPlayerIsMoving())
			and  GroupedPlayersHealth(vPlayerToHeal, 40, 77) >= 3 
			then
				if not ccrPlayerIsCastingSpell("Chain Heal")
						then SpellStopCasting() end 
				if not ccrPlayerIsCastingSpell("Chain Heal")
					then SpellStopCasting() end 
					ccrCast("Chain Heal", vPlayerToHeal)
					if vTargetPlayerToHeal then TargetUnit(vPlayerToHeal)
			        return
				end	
		    end
			-- Greater Healing Wave at 50%
			if vPlayerHealth <= 40
			and SpellIsReady("Greater Healing Wave")
			and not ccrTargetName() == "Malkorok"
			and (ccrPlayerHasBuff("Spiritwalker's Grace") or not ccrPlayerIsMoving())
			then
				ccrCast("Greater Healing Wave", vPlayerToHeal)
				if vTargetPlayerToHeal then TargetUnit(vPlayerToHeal) end
				return
			end
			-- Riptide at 90%  
			if vPlayerHealth <= 25
			and not ccrUnitHasMyBuff(vPlayerToHeal, "Riptide")
			then
				ccrCast("Riptide", vPlayerToHeal)
				if vTargetPlayerToHeal then TargetUnit(vPlayerToHeal) end
				return
			else 
				if ccrPlayerIsMoving()
					and not ccrUnitHasMyBuff(vPlayerToHeal, "Riptide")
					then
				ccrCast("Riptide", vPlayerToHeal)
				if vTargetPlayerToHeal then TargetUnit(vPlayerToHeal) end
				return
				end
			end	
				-- Healing Wave 99%
				if vPlayerHealth <= 99
				and SpellIsReady("Healing Wave")
				and (ccrPlayerHasBuff("Spiritwalker's Grace") or not ccrPlayerIsMoving())
				then
					ccrCast("Healing Wave", vPlayerToHeal)
					if vTargetPlayerToHeal then TargetUnit(vPlayerToHeal) end
					return

			end
	    end
    end
end	
